package org.go.work;

import java.io.Serializable;
import java.util.Iterator;
import java.util.Map;
import java.util.Set;

/**
 * 
 * @author hejie
 *
 */
public class WorkDataMap implements Serializable {
	/**
	 * 
	 */
	private static final long serialVersionUID = 6947185035366590813L;

	private boolean dirty = false;

	private Map map;

	public WorkDataMap() {

	}

	public WorkDataMap(Map<?, ?> map) {
		this();
		putAll(map);
	}

	private boolean getBooleanValueFromString(String key) {
		Object obj = get(key);
		return Boolean.valueOf((String) obj).booleanValue();
	}

	public void clear() {

	}

	public void clearDirtyFlag() {

	}

	public boolean containsKey(String propWaitForProcess) {
		return false;
	}

	public Object[] get(String ejbArgsKey) {
		return null;
	}

	public boolean getBoolean(String key) {
		Object obj = get(key);
		try {
			if (obj instanceof Boolean)
				return ((Boolean) obj).booleanValue();
			return Boolean.parseBoolean((String) obj);
		} catch (Exception e) {
			throw new ClassCastException("Identified object is not a Boolean.");
		}
	}

	public boolean getBooleanValue(String key) {
		Object obj = get(key);
		if (obj instanceof String) {
			return getBooleanValueFromString(key);
		} else {
			return getBoolean(key);
		}
	}

	public int getInt(String jmsAckMode) {

		return 0;
	}

	public String[] getKeys() {
		return null;
	}

	public String getString(String ejbJndiNameKey) {
		return null;
	}

	public Map<?, ?> getWrappedMap() {

		return null;
	}

	public boolean isDirty() {

		return false;
	}

	public Set<String> keySet() {
		return map.keySet();
	}

	/**
	* <p>
	* Adds the given <code>Object</code> value to the <code>StringKeyDirtyFlagMap</code>.
	* </p>
	*/
	public Object put(Object key, Object value) {
		if (!(key instanceof String)) {
			throw new IllegalArgumentException("Keys in map must be Strings.");
		}
		return map.put(key, value);
	}

	public void put(String string, Object object) {

	}

	public void put(String string, String string2) {

	}

	/**
	 * <p>
	 * Adds the name-value pairs in the given <code>Map</code> to the 
	 * <code>StringKeyDirtyFlagMap</code>.
	 * </p>
	 * 
	 * <p>
	 * All keys must be <code>String</code>s.
	 * </p>
	 */
	public void putAll(Map map) {
		for (Iterator entryIter = map.entrySet().iterator(); entryIter.hasNext();) {
			Map.Entry entry = (Map.Entry) entryIter.next();
			// will throw IllegalArgumentException if key is not a String
			put(entry.getKey(), entry.getValue());
		}
	}

	public int size() {
		return map.size();
	}
}
